package j2eelogin.actions;

import j2eelogin.actionforms.AFLogin;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class ALogin extends Action {
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest req, HttpServletResponse res) throws Exception {

		if (form instanceof AFLogin) {
			AFLogin loginForm = (AFLogin) form;

			if (loginForm.getlogin().equals("root")
					&& loginForm.getpassword().equals("root"))

				return mapping.findForward("sucessAdmin");
			else if(loginForm.getlogin().equals("user")
					&& loginForm.getpassword().equals("user"))
				return mapping.findForward("sucess");

			// return mapping.findForward("fail");
		}
		
		return mapping.findForward("fail");

	}
}
